package net.jueb.protobufs.server;
import net.jueb.protobufs.pojo.UsualMessageProtos.Login;
import net.jueb.protobufs.pojo.UsualMessageProtos.Logout;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
public class ProtobufServerHandler extends ChannelHandlerAdapter{

	
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg)
			throws Exception {
		if(msg==null)
		{
			return;
		}
		if(msg instanceof Login)
		{
			System.out.println("收到登录请求\n"+msg);
		}else if(msg instanceof Logout)
		{
			System.out.println("收到登出请求\n"+msg);
		}else
		{
			System.out.println("收到消息:"+msg);
		}
	}
	
	@Override
	public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
			throws Exception {
		System.out.println("收到用户触发事件:"+evt.toString());
	}
	
	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
			throws Exception {
		System.out.println("收到用户触发异常:"+cause.getMessage());
//		cause.printStackTrace();
//		ctx.close();
	}
}
